#!/bin/bash

:<< 前置知识
# 系统安装时设置的环境变量
$EXEPATH

# 运行gitbash时加载的配置文件
C:\Program Files\Git\etc\bash.bashrc 
前置知识

echo $GIT
echo $GITCMD
echo $GITETC

# GIT="$EXEPATH"
# GITCMD="$EXEPATH\\cmd"
# GITETC="$EXEPATH\\etc"
# # 运行gitbash时加载的配置文件
# GITBASHRC="bash.bashrc"


# # 读取文件
# file=$(cat $GITBASHRC)

# # 找到需要移除的内容
# start="#####custom_env_start#####"
# end="#####custom_env_end#####"
# # custom="$(echo $file | grep -Pzo "^((?!$start[\s\S]*$end).)*")"
# custom="$(echo $file | grep -Pzo "$start[\s\S]*$end")"
# echo $custom
# sed -e '/^#####custom_env_start#####[/s/S]*#####custom_env_end#####$/d' $GITBASHRC
# 剔除之前内容

# 添加自定义内容


# cat $GITBASHRC

# echo $file > "$GITBASHRC"

# cat <<EOF >"$GITBASHRC"
# $file
# GIT="$EXEPATH"
# GITCMD="$EXEPATH\\cmd"
# GITETC="$EXEPATH\\etc"
# # 运行gitbash时加载的配置文件
# GITBASHRC="bash.bashrc"
# EOF

# cat "$GITBASHRC"
# regex="/(#####custom_env_start#####)((.*\n)*)(#####custom_env_end#####)/"

# custom="$(<bash.bashrc | grep -Pzo '((?s)#####custom_env_start#####.*#####custom_env_end#####)')"
# echo $custom
# egrep "^#####custom_env_start#####([\s\S]*)#####custom_env_end#####$" bash.bashrc
# awk -F:'/#####custom_env_start#####([/s/S]*)#####custom_env_end#####/{print $1}' file
# echo $file

#  if [ "$file" =~ $regex ];
#  then
# echo "y"
#  else
#  echo "n"
#  fi


# echo $("S.*l" =~ "a.txt")
# echo "$start
# GIT='"$GIT"'
# GITCMD='"$GITCMD"'
# GITETC='"$GITETC"'
# $end
# " >> $GITBASHRC




# # echo ${file%"$start"}
# echo ${file##$start*$end} 

# s="ch"
# n="n"
# string="china IS niuBIlity2018"
#  echo ${string##$s*$n}
# # # 1.配置自定义环境变量





# echo "
# GIT=""$GIT""
# GITCMD=""$GITCMD""
# GITETC=""$GITETC""
# "

# # echo "
# # Git安装目录：${GIT}
# # Git命令行目录：${GITCMD}
# # Git配置文件目录：${GITETC}
# # "

# start="#####custom_env_start#####"
# end="#####custom_env_end#####"
# file=$(cat "$GITBASHRC")
# echo $file

# # 运行gitbash时加载的配置文件
# #cat "$GITBASHRC"

# #read -p file < a.txt

# # echo $(cat tr'\r''\n'< a.txt)



